package com.prognos.web.controller;

import com.prognos.service.harvester.HarvesterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping(value = "/harvest")
public class HarvesterController {

    private HarvesterService harvesterService;

    private static final String REDIRECT_HOME = "redirect:/";

    @Autowired
    public HarvesterController(HarvesterService harvesterService) {
        this.harvesterService = harvesterService;
    }

    @RequestMapping(method = RequestMethod.POST)
    public String start(ModelMap modelMap) {
        harvesterService.startHarvest();
        return REDIRECT_HOME;
    }
}
